<template tag="以下文档内容为hycli自动生成">
  <div style="height: 100%">
    <div style="margin:0.8rem;"><h5 style="display:inline">通知消息</h5><span style="margin-left: 0.5rem; color:#999"> 任务分配或修改后的邮件通知记录</span>
    </div>
    <hr style="margin-top:0;color:#999"/>
<div class="query">
    
    <el-form :model="form_aaazk" inline >
        <!-- 日期控件个数： 0 -->
        <!--用户 下拉控件多选 -->
        <el-form-item>
            <el-select v-model="form_aaazk.staff_id" filterable clearable multiple collapse-tags  style="width: 140px"
            collapse-tags-tooltip placeholder="用户">
                <el-option v-for="item in staff_idList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!-- 控件个数：[{"index":26,"raw":"title","name":"title","cname":"Title","type":{"raw":"varchar(64)","name":"varchar","len":64,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","l","le","v","c","u","DN","rows(1)"],"desc":{"raw":"消息标题","name":"消息标题"}}] -->
         <el-form-item>
            <el-input clearable style="width: 180px" v-model="form_aaazk.single_text_value" maxlength="32"
                placeholder="关键字" >
                <template #prepend>
                    <el-select v-model="form_aaazk.single_text_name" placeholder="查询类型" style="width:84px;">
                        <el-option
                        v-for="item in multiQueryText"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                      </el-select>
                  </template>
            </el-input>
        </el-form-item>

        <span class="ddl">
        </span>
        <el-form-item>
            <el-space wrap>
                <el-button type="primary" icon="Search" @click="onQuery(true)">查询</el-button>
                <el-button :type="$js.page.tagColor(0)"  icon="Plus"  @click="show_cmpnt_aaazo">添加</el-button>
            </el-space>
        </el-form-item>
        

        <!-- xtabs -->
        

    </el-form>
</div>
<div>
   <aaazo ref="cmpnt_aaazo" @onsaved="onQuery"></aaazo>
   <aaazl ref="cmpnt_aaazl" @onsaved="onQuery"></aaazl>
   <aaazm ref="cmpnt_aaazm" @onsaved="onQuery"></aaazm>
   <aaazn ref="cmpnt_aaazn" @onsaved="onQuery"></aaazn>
</div>
<div class="list">
    <el-table :data="dataList_aaazk"
    
    v-loading="conf.loading" stripe  style="width: 100%;height:calc(100vh - 160px)"
         empty-text="无数据">le
<el-table-column width="24px" type="expand">
    <template #default="view">
        <el-row :gutter="24">
            <el-col :span="5" class="text-right" style="min-height:26px">消息:</el-col>
            <el-col :span="7" v-text="view.row.le_mn_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">用户:</el-col>
            <el-col :span="7" v-text="view.row.staff_id_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">消息类型:</el-col>
            <el-col :span="7" v-text="view.row.msg_type_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.msg_type,'msg_type')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">消息标题:</el-col>
            <el-col :span="7" v-html="view.row.le_title||'-'" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">消息内容:</el-col>
            <el-col :span="7" v-text="view.row.le_content" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">是否已读:</el-col>
            <el-col :span="7" v-text="view.row.is_read_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.is_read,'is_read')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">发送状态:</el-col>
            <el-col :span="7" v-text="view.row.status_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.status,'status')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">结果消息:</el-col>
            <el-col :span="7" v-html="view.row.le_msg||'-'" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">创建时间:</el-col>
            <el-col :span="7" v-text="view.row.le_create_time" style="min-height:26px" ></el-col>
        </el-row>
    </template>
</el-table-column>
        
        	<!--mn_id text -->
        <el-table-column  show-overflow-tooltip    align="center" label="消息" >
            <template #default="scope">
                  <span>{{ scope.row.mn_id||'-' }}</span>
              </template>
        </el-table-column>
        	<!--staff_id multiselect -->
        <el-table-column  :filters="staff_idList" :filter-method="$js.page.columnfilter" column-key="staff_id"     prop="staff_id" align="center" label="用户">
            <template #default="scope">
                <span 
                    v-text="scope.row.staff_id_label"></span>
            </template>
        </el-table-column>
        	<!--msg_type select -->
        <el-table-column     prop="msg_type" align="center" label="消息类型">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.msg_type,'msg_type')" 
                    v-text="scope.row.msg_type_label"></span>
            </template>
        </el-table-column>
        	<!--title text -->
        <el-table-column  show-overflow-tooltip    align="center" label="消息标题" >
            <template #default="scope">
                  <span>{{ scope.row.title||'-' }}</span>
              </template>
        </el-table-column>
        	<!--is_read select -->
        <el-table-column     prop="is_read" align="center" label="是否已读">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.is_read,'is_read')" 
                    v-text="scope.row.is_read_label"></span>
            </template>
        </el-table-column>
        	<!--status select -->
        <el-table-column     prop="status" align="center" label="发送状态">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.status,'status')" 
                    v-text="scope.row.status_label"></span>
            </template>
        </el-table-column>
        	<!--create_time text -->
        <el-table-column  show-overflow-tooltip    align="center" label="创建时间" >
            <template #default="scope">
                  <span>{{ scope.row.create_time||'-' }}</span>
              </template>
        </el-table-column>

<el-table-column fixed="right" align="center" label="操作" width="168">
    <template #default="scope">
        <div class="opts">
            <el-button   type="text" @click="show_cmpnt_aaazl(scope.row)" >详情 </el-button>
            <el-button   type="text" @click="show_cmpnt_aaazm(scope.row)" >修改 </el-button>
            <el-button   type="text" @click="show_cmpnt_aaazn(scope.row)" >删除 </el-button>
        </div>
    </template>
</el-table-column>
    </el-table>
    <el-pagination :currentPage="form_aaazk.pi" :page-size="form_aaazk.ps"
        style="position: absolute; right: 30px;bottom:6px;" :page-sizes="[10,15,20,30, 50, 100]" :background="false" small
        layout="total,sizes,prev, pager, next, jumper" :total="total_aaazk" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
</div>
  </div>
</template>
<script>
// 添加
import aaazo from "@/views/ws/message/message_notification.add"
// 详情
import aaazl from "@/views/ws/message/message_notification.view"
// 修改
import aaazm from "@/views/ws/message/message_notification.edit"
// 删除
import aaazn from "@/views/ws/message/message_notification.cnfrm"



export default {
components: {
    aaazo,
    aaazl,
    aaazm,
    aaazn,
},
data() {
  return {
    shortcuts: this.$js.page.latestDays(),
    cmpnt_funcs:{},
    conf: {
      loading: false,
      progressColor: this.$theia.env.conf.progress || []
    },
    ganttIdx: -1,
        form_aaazk: {
            pi: 1,
            ps: 15,
            disabled:false,
            single_date_range_name:"",
            single_date_range_value:[],
            single_text_name:"",
            single_text_value:"",
            staff_id:[],
            title:"",
            },
            staff_idExts:[],
            staff_idList:[],
            msg_typeList:[],
            is_readList:[],
            statusList:[],
            dataList_aaazk:[],
            multiQueryDateRange:[],
            multiQueryText:[{label:"消息标题",value:"title"},],
            total_aaazk:0,
            note_dataList:[],
};
  },
mounted() {
  this.loadEnums_aaazk()
  this.form_aaazk.single_date_range_name = (this.multiQueryDateRange[0]||{}).value
  this.form_aaazk.single_text_name = (this.multiQueryText[0]||{}).value
  this.cmpnt_funcs["aaazo"] = this.show_cmpnt_aaazo
  this.cmpnt_funcs["aaazl"] = this.show_cmpnt_aaazl
  this.cmpnt_funcs["aaazm"] = this.show_cmpnt_aaazm
  this.cmpnt_funcs["aaazn"] = this.show_cmpnt_aaazn

  this.form_aaazk = Object.assign(this.form_aaazk,this.$route.params)
  this.queryData_aaazk ()
    },
methods: {
  ganttChange(id) {
      this.ganttIdx = id
    },

queryData_aaazk(mform = {},nform={}){
    //构建查询参数
    let queryForm = Object.assign({},this.form_aaazk)
    queryForm = Object.assign(queryForm,nform||{})
    
    //处理多个日期选择
    queryForm[this.form_aaazk.single_date_range_name] = this.form_aaazk.single_date_range_value
    queryForm[this.form_aaazk.single_text_name] = this.form_aaazk.single_text_value
   
    //处理日期范围选择
      queryForm.staff_id = (queryForm.staff_id||[]).join(",")

    queryForm[this.form_aaazk.single_date_range_name] = null
    queryForm.single_date_range_value = null
    queryForm.single_date_range_name = null

    queryForm.single_text_value = null
    queryForm.single_text_name = null
 
    //处理关联表message_notification message_notification message_notification
   
    //发送查询请求
    let that = this
    that.conf.loading = true
    //构建统计查询
  //数据查询
  this.$theia.http.get("/ws/message/notification/query",queryForm).then(res=>{
      if((res.items||[]).length < (queryForm.ps||10)){
        that.form_aaazk.disabled = true
      }
      that.conf.loading = false
      that.dataList_aaazk = res.items||[]
      that.total_aaazk = res.count
      that.resetItemData_aaazk(that,that.dataList_aaazk)
    });
  },

  resetItemData_aaazk(that,lst){
    lst.forEach(item => {
      item.__raw = Object.assign({}, item)
    item.staff_id_label = that.$theia.enum.getName("staff_info",item.staff_id)
    item.msg_type_label = that.$theia.enum.getName("msg_type",item.msg_type)
    item.is_read_label = that.$theia.enum.getName("bool",item.is_read)
    item.status_label = that.$theia.enum.getName("msg_status",item.status)
    item.mn_id_progress = item.mn_id
    item.staff_id_progress = item.staff_id
    item.msg_type_progress = item.msg_type
    item.title_progress = item.title
    item.content_progress = item.content
    item.is_read_progress = item.is_read
    item.status_progress = item.status
    item.msg_progress = item.msg
    item.create_time_progress = item.create_time
    item.le_mn_id = item.mn_id
    item.le_staff_id = item.staff_id
    item.le_msg_type = item.msg_type
    item.le_title = item.title
    item.le_content = item.content
    item.le_is_read = item.is_read
    item.le_status = item.status
    item.le_msg = item.msg
    item.le_create_time = item.create_time
    if(item.children){
      that.resetItemData_aaazk(that,item.children)
    }
  });
  },
    loadEnums_aaazk(){
        //用户
        this.staff_idList = this.$theia.enum.get("staff_info","","" ,false,"")
        //用户
        this.staff_idList = this.$theia.enum.get("staff_info","","" ,false,"")
        //消息类型
        this.msg_typeList = this.$theia.enum.get("msg_type","","" ,false,"")
        //是否已读
        this.is_readList = this.$theia.enum.get("bool","","" ,false,"")
        //发送状态
        this.statusList = this.$theia.enum.get("msg_status","","" ,false,"")
    },

  handleSizeChange(ps){
    this.form_aaazk.ps = ps
    this.onQuery(true)
  },
  handleCurrentChange(pi){
    this.form_aaazk.pi = pi
    this.onQuery()
  },
  onQuery(refresh){
    if(refresh){
      this.form_aaazk.pi = 1
    }
    this.queryData_aaazk ()
  },
show_cmpnt(cmd,row){
  if(this.cmpnt_funcs[cmd]){
    this.cmpnt_funcs[cmd](row)
  }
},
  //详情
  show_cmpnt_aaazl(fm = {}){
    let query = {} 
    query.mn_id = fm.mn_id|| fm.le_mn_id 
    query.staff_id = fm.staff_id|| fm.le_staff_id 
    query.msg_type = fm.msg_type|| fm.le_msg_type 
    query.title = fm.title|| fm.le_title 
    query.content = fm.content|| fm.le_content 
    query.is_read = fm.is_read|| fm.le_is_read 
    query.status = fm.status|| fm.le_status 
    query.msg = fm.msg|| fm.le_msg 
    query.create_time = fm.create_time|| fm.le_create_time 
    query.mn_id = fm.mn_id

      //2023.4.18添加---

    query.$title="详情"
    this.$refs.cmpnt_aaazl.show(query)
  },
  //添加
  show_cmpnt_aaazo(fm = {}){
    let query = {} 
    query.staff_id = fm.staff_id|| fm.le_staff_id 
    query.msg_type = fm.msg_type|| fm.le_msg_type 
    query.title = fm.title|| fm.le_title 
    query.content = fm.content|| fm.le_content 
    query.mn_id = fm.mn_id

      //2023.4.18添加---

    query.$title="添加"
    this.$refs.cmpnt_aaazo.show(query)
  },
  //修改
  show_cmpnt_aaazm(fm = {}){
    let query = {} 
    query.msg_type = fm.msg_type|| fm.le_msg_type 
    query.title = fm.title|| fm.le_title 
    query.content = fm.content|| fm.le_content 
    query.mn_id = fm.mn_id

      //2023.4.18添加---

    query.$title="修改"
    this.$refs.cmpnt_aaazm.show(query)
  },
  //删除
  show_cmpnt_aaazn(fm = {}){
    let query = {} 
    query.mn_id = fm.mn_id|| fm.le_mn_id 
    query.mn_id = fm.mn_id

      //2023.4.18添加---

    query.$title="删除"
    this.$refs.cmpnt_aaazn.show_aaazn(query)
  },
},
};
</script>
<style>
.el-dialog{
  border-radius:5px !important
}
</style>
<style scoped>
.el-form-item {
  margin-right: 10px !important;
}

.opts .el-button--small {
  margin-left: 0px;
  padding-left: 0px;
  margin-right: 4px;
}

/deep/.el-table td.el-table__cell div {
  vertical-align: middle;
}
/deep/.el-button+.el-dropdown{
  margin-left:0px;
}
/deep/.el-button+.el-button{
  margin-left:0px;
}
.el-button{
  padding-left: 6px !important;
  padding-right: 6px !important;
}
.blist {
  margin-bottom: 8px;
  width: 100%;
}

.blist .el-radio-group {
  margin-right: 8px;
}

.ddl {
  margin-bottom: 8px;
  width: 100%;

}

.ddl .el-dropdown {
  margin-right: 8px;
}

.listbar {
  margin-bottom: 8px;
  text-align: center;
}
 .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 0.65rem;
}
/deep/.el-button--small{
  padding: 5px 4px;
}

.prepend /deep/.el-input__wrapper{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.prepend+/deep/.el-date-editor{
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-left:0;
}

</style>